import numpy as np

A = [[1, 1 / 4, 3],
     [4, 1, 10],
     [1 / 3, 1 / 10, 1],
     ]
A = np.array(A)
# 1重要性 2结构 3难度

n = 3
RI = 0.58
eig_value, eig_vector = np.linalg.eig(A)
lambda_max = max(eig_value)
print((lambda_max - n) / (n - 1) / RI)
eig_vector_0 = eig_vector[:, 0].real
eig_vector_0_norm = eig_vector_0 / eig_vector_0.sum()
print(eig_vector_0_norm)
B = np.array(
    [[0.11820904, 0.02942409, 0.05007597, 0.06424092, 0.11119691, 0.05852617, 0.07122805, 0.05402752, 0.03735846,
      0.12995429, 0.01875739, 0.03199697, 0.04192901, 0.01314893, 0.02445963, 0.09667244, 0.04879421],
     [0.04930357, 0.070366, 0.06841694, 0.05849312, 0.05267622, 0.0691527, 0.07066623, 0.04903114, 0.08067508,
      0.04359464, 0.06054851, 0.06395454, 0.04430334, 0.04418005, 0.04299335, 0.05909203, 0.07255255],
     [0.00882751, 0.01797439, 0.01659151, 0.01335179, 0.05107547, 0.03180043, 0.01197872, 0.04276139, 0.04087487,
      0.00688577, 0.01678849, 0.00450645, 0.02470153, 0.31747055, 0.31747055, 0.0461579, 0.03078269]])
It = {5:1.2, 6:1.1, 10:1.2, 16:1.5}
Id = {5:1.2, 6:1.1, 10:1.2, 16:1.5}
for key, value in It.items():
    B[0][key - 1] *= value
B[0] = B[0] / B[0].sum()
for key, value in Id.items():
    B[2][key - 1] *= value
B[2] = B[2] / B[2].sum()
result = ((B.transpose() @ eig_vector_0_norm).argsort() + 1)[::-1]
print(result)

# [ 9  7 16 17  6  5  3  1  2 15 10 14  4 12  8 11 13]
# [ 9  7 16 17  6  5  3  1 15  2 14 10  4 12 11  8 13] 0.5
# [ 6  3  9  7 17 16  5  2  1 15 14 10  4 12 11  8 13] 2 2
# [ 9  7 17 16  6 15  5  3 14 13  2  1 10  4 12 11  8] 1.5 1.5 {11:1.5, 13:3, 14:1.5, 15:1.5}
# [16  9  5  7 17  6  3  1  2 15 14 10  4 12 11  8 13] {5:1.2, 16:1.5} {16:1.5}
# [16  9  5  7  6 17  3 10  2  1 15 14  4 12 11  8 13] {5:1.2, 6:1.1, 10:1.2, 16:1.5}



